clear 
// import the full data.

use "full-data-clean.dta"

gen UK=.
replace UK=1 if country==0
replace UK=0 if country==1
tab UK

gen US=.
replace US=1 if country==1
replace US=0 if country==0
tab US

replace country=1 if US==1
replace country=2 if UK==1

tab country // US, UK

lab var catrust "trust in minipublics"
********************************************************************************
******************DESCRIPTIVE STATS*********************************************
********************************************************************************
by country, sort : summarize compliance
by country, sort: summarize catrust 

by country, sort: summarize threat1
by country, sort: summarize threat2
by country, sort: summarize threat3
alpha threat2 threat3 threat1 if country==1
alpha threat2 threat3 threat1 if country==2

// strongovpref is the index of the authoritarian attitudes, created at country level when cleaning the data 

by country,sort: summarize strongovpref

// US sample: trust in the federal government and state
summarize federaltrust
summarize statetrust

by country, sort: summarize trust_parliament
by country, sort: summarize trust_legal
by country, sort: summarize trust_police
by country,sort: summarize trust_politician
by country, sort: summarize trust_parties
by country, sort: summarize catrust

// the correlation between interpersonal trust and trust in CAs
pwcorr interptrust catrust caqualified family_trust neighb_trust know_trust stranger_trust relig_trust nation_trust

********************************************************************************
**************************** MAIN MANUSCRIPT: TABLE 2***************************
********************************************************************************
reg compliance ib(1). treatment
estimates store m1

reg compliance ib(1).treatment if country==1   //US
estimates store m2

reg compliance ib(1).treatment if country==2		// UK
estimates store m3

reg compliance ib(2).treatment
estimates store m4

reg compliance ib(3).treatment
estimates store m5

reg compliance ib(4).treatment
estimates store m6

esttab m1 m2 m3 m4 m5 m6 using "regressiontabell_covid4.rtf", se r2 ar2 replace

********************************************************************************
**************************** MAIN MANUSCRIPT: FIGURE 3**************************
********************************************************************************
reg compliance i.treatment c.catrust i.treatment#c.catrust //pooled
estimates store trustPooled
coefplot trustPooled, drop(_cons) ci(95) graphregion(color(white)) grid(none) xline(0, lcolor(gs10)) ciopts(recast(rcap))

********************************************************************************
**************************** MAIN MANUSCRIPT: FIGURE 4**************************
********************************************************************************
reg compliance i.treatment c.catrust i.treatment#c.catrust //pooled
margins treatment, at(catrust=(0(1)10)) post
margins, coeflegend
marginsplot

********************************************************************************
**************************** MAIN MANUSCRIPT: FIGURE 5**************************
********************************************************************************
reg compliance i.treatment c.strongovpref i.treatment#c.strongovpref
estimates store a
coefplot a, drop(_cons) ci(95) graphregion(color(white)) grid(none) xline(0, lcolor(gs10)) ciopts(recast(rcap))

********************************************************************************
**************************** MAIN MANUSCRIPT: FIGURE 6**************************
********************************************************************************

reg compliance i.treatment i.treatment#c.strongovpref
margins treatment, at(strongovpref=(0(1)10))
marginsplot

********************************************************************************
**************************** MAIN MANUSCRIPT: FIGURE 7**************************
********************************************************************************
lab var interptrust "interpersonal trust"
lab var trust_expert "trust in experts"
lab var trust_politician "trust in politicians"
lab var age "age"
lab var ideology_US "ideology US"
lab var ideology_UK "ideology UK"
lab var partisanUS "partisanship US"
lab var partisanUK "partisanship UK"
lab var awareness_minipublic "minipublic awareness"
fre partisanUS
recode partisanUS (4=.)
fre partisanUK
recode partisanUK (7 8=7)


reg compliance i.treatment c.catrust awareness_minipublic strongovpref indexthreat_re trust_expert interptrust trust_politician i.gender age 
estimates store pooled

coefplot pooled, drop(_cons) ci(95) graphregion(color(white)) grid(none) xline(0, lcolor(gs10)) ciopts(recast(rcap))

********************************************************************************
**************************** APPENDIX ******************************************
********************************************************************************

fre gender if country==1
fre age if country==1
fre usedu

//1- did not graduate from high school, 2-high school graduate, 3-some college, but no degree, 4-completed a degree at college level, 5-postgraduate degree 

fre ideology_US

**** UK SAMPLE

fre gender if country==2
fre age if country==2
fre educaUK if country==2

// 1- no qual; 2- GSCE/0-LEVEL/....EQUIV., 3-NVQ4/NVQ5 or equiv., 4-Degree/HNC/teacher training/nursing, 5-PhD/Dphil or equival. 6 -other.

tab partisanUK
tab ideology_US

// appendix  E

reg compliance i.treatment c.catrust i.treatment#c.catrust if country==1
estimates store trustUS
reg compliance i.treatment c.catrust i.treatment#c.catrust if country==2
estimates store trustUK
reg compliance i.treatment c.catrust i.treatment#c.catrust //pooled
estimates store trustPooled
coefplot trustUS trustUK trustPooled, drop(_cons) ci(95) graphregion(color(white)) grid(none) xline(0, lcolor(gs10)) ciopts(recast(rcap))


// FULL MODELS WITH SOME COVARIATES....

lab var ideology_US "ideology US"
lab var ideology_UK "ideology UK"

lab var partisanUS "partisanship US"
lab var partisanUK "partisanship UK"

lab var awareness_minipublic "minipublic awareness"

fre partisanUS
recode partisanUS (4=.)

fre partisanUK
recode partisanUK (7 8=7)


///  online appendix F

reg compliance i.treatment c.catrust awareness_minipublic strongovpref indexthreat_re trust_expert interptrust trust_politician ideology_US i.partisanUS i.gender age usedu if country==1 
estimates store US

reg compliance i.treatment c.catrust awareness_minipublic strongovpref indexthreat_re trust_expert interptrust trust_politician ideology_UK i.partisanUK i.gender age educaUK if country==2
estimates store UK

coefplot US || UK, drop(_cons) ci(95) graphregion(color(white)) grid(none) xline(0, lcolor(gs10)) ciopts(recast(rcap))

////// online appendix G 

cibar compliance, over1(treatment) over2(partisanUS) ciopts(lcolor(red)) barcol(ltblue midblue blue dkblue) graphopts(ylab(1(1)10,nogrid) name(graph_1, replace))

cibar compliance, over1(treatment) over2(partisanUK) ciopts(lcolor(red)) barcol(ltblue midblue blue dkblue) graphopts(ylab(1(1)10,nogrid) name(graph_1, replace))

*** by ideology and partisanship

reg compliance i.treatment c.catrust awareness_minipublic strongovpref indexthreat_re trust_expert interptrust trust_politician i.gender age usedu i.partisanUS ideology_US if country==1
estimates store a
coefplot a, drop(_cons) ci(95) graphregion(color(white)) grid(none) xline(0, lcolor(gs10)) ciopts(recast(rcap))


reg compliance i.treatment c.catrust awareness_minipublic strongovpref indexthreat_re trust_expert interptrust trust_politician i.gender age educaUK i.partisanUK ideology_UK if country==2
estimates store b

coefplot a b, drop(_cons) ci(95) graphregion(color(white)) grid(none) xline(0, lcolor(gs10)) ciopts(recast(rcap))


/// online appendix I - manipulation check
tab manipulationcheck if country==1
tab manipulationcheck if country==2

/// for CACE
*** creating binary variables
gen treat14=.
replace treat14=0 if treatment==1
replace treat14=1 if treatment==4
fre treatment
fre treat14

tab manipulation


/// only for those in the control and those in the minipublic conditions 
gen mc=.
recode mc (.=1) if treatment==1&manipulation==1 //control
recode mc (.=0) if treatment==1&manipulation!=1
recode mc (.=1) if treatment==4&manipulation==4 //minipublic
recode mc (.=0) if treatment==4&manipulation!=4
recode mc (.=0) if treatment==1&manipulation==5 //dont remember
recode mc (.=0) if treatment==4&manipulation==5 //dont remember

tab treatment
tab manipulation
tab mc

tab mc if country==1
tab mc if country==2

tab mc if country==1&treatment==4
tab mc if country==2&treatment==4

// so the mc captures compliance in the minipublic and control conditions only to make the CACE analysis more correctly and capture the effect of the minipublic treatment
// rather than compliance in all four conditions 

// we are doing the same for other variables

// control vs. politican deliberation

gen mc_2=.

recode mc_2 (.=1) if treatment==1&manipulation==1 //control
recode mc_2 (.=0) if treatment==1&manipulation!=1
recode mc_2 (.=0) if treatment==1&manipulation==5 //dont remember

recode mc_2  (.=1) if treatment==2&manipulation==2 //politiciandelibreation
recode mc_2 (.=0) if treatment==2&manipulation!=2
recode mc_2 (.=0) if treatment==2&manipulation==5 //dont remember

tab mc_2

tab mc_2 if country==1&treatment==2
tab mc_2 if country==2&treatment==2

// the last one is for public consultation
gen mc_3=.

recode mc_3 (.=1) if treatment==1&manipulation==1 //control
recode mc_3 (.=0) if treatment==1&manipulation!=1
recode mc_3 (.=0) if treatment==1&manipulation==5 //dont remember

recode mc_3 (.=1) if treatment==3&manipulation==3 //public consultation
recode mc_3 (.=0) if treatment==3&manipulation!=3
recode mc_3 (.=0) if treatment==3&manipulation==5 //dont remember

tab mc_3

tab mc_3 if country==1&treatment==3
tab mc_3 if country==2&treatment==3

****
gen treat12=.
replace treat12=0 if treatment==1
replace treat12=1 if treatment==2
fre treatment
fre treat12

gen treat13=.
replace treat13=0 if treatment==1
replace treat13=1 if treatment==3
fre treatment
fre treat13

////

ivregress 2sls compliance (mc_2=treat12) 
estimates store a

ivregress 2sls compliance (mc_3=treat13)
estimates store b

ivregress 2sls compliance (mc=treat14)
estimates store c

coefplot a b c, xline(0) drop(_cons)


******* online appendix L

reg strongovpref indexthreat_re 


******** online appendix M
reg compliance i.treatment c.interptrust i.treatment#c.interptrust
estimates store a
coefplot a, drop(_cons) ci(95) graphregion(color(white)) grid(none) xline(0, lcolor(gs10)) ciopts(recast(rcap))


